home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / CheckUser / Main.C < prev    next >
C/C++ Source or Header  |  1996-08-01  |  4KB  |  183 lines

  1. /*
  2.  
  3.   CheckUser
  4.   =========
  5.  
  6.     This door is called when a user has logged on to the system, just after frontend
  7.     It's function is to check all the user's settings are OK, (e.g. LastConf still
  8.     exsists, mail scan pointers are in valid ranges, etc etc)
  9.  
  10.     You can also use it for sentby checking and the like...
  11.  
  12. */
  13.  
  14. #include <exec/types.h>
  15. #include <exec/memory.h>
  16. #include <dos/dos.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/dos_protos.h>
  19. #include <clib/alib_protos.h>
  20.  
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <stdio.h>
  24. #include <ctype.h>
  25. #include <time.h>
  26.  
  27. #include <HBBS/ANSI_Codes.h>
  28. #include <HBBS/Defines.h>
  29. #include <HBBS/types.h>
  30. #include <HBBS/structures.h>
  31. #include <HBBS/hbbscommon_protos.h>
  32. #include <HBBS/hbbscommon_pragmas.h>
  33. #include <HBBS/Hbbsnode_protos.h>
  34. #include <HBBS/Hbbsnode_pragmas.h>
  35.  
  36. struct Library *HBBSCommonBase=NULL;
  37. struct Library *HBBSNodeBase=NULL;
  38.  
  39. struct BBSGlobalData *BBSGlobal=NULL;
  40. struct NodeData *N_ND=NULL;
  41. int    N_NodeNum=-1;
  42. char   outstr[1024];
  43.  
  44. int    gargc;
  45. char   **gargv;
  46.  
  47. #ifdef __SASC
  48. int CXBRK(void) { return(0); }
  49. int _CXBRK(void) { return(0); }
  50. void chkabort(void) {}
  51. #endif
  52.  
  53.  
  54. static VOID cleanup(ULONG num)
  55. {
  56.   if (HBBSNodeBase)
  57.   {
  58.     HBBS_CleanUpDoor();
  59.     CloseLibrary (HBBSNodeBase);
  60.   }
  61.  
  62.   if (HBBSCommonBase)
  63.   {
  64.     HBBS_CleanUpCommon();
  65.     CloseLibrary (HBBSCommonBase);
  66.   }
  67.  
  68.   if (num) printf("Door Error = %d\n",num);
  69.  
  70.   exit(0);
  71. }
  72.  
  73. static VOID init(char *name)
  74. {
  75.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  76.   {
  77.     cleanup(1);
  78.   }
  79.  
  80.   if (!(HBBS_InitCommon()))
  81.   {
  82.     cleanup(2);
  83.   }
  84.  
  85.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  86.   {
  87.     cleanup(3);
  88.   }
  89.  
  90.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  91.   {
  92.     cleanup(4);
  93.   }
  94.   SetProgramName(name);
  95. }
  96.  
  97. void DoorMain( void )
  98. {
  99.   int loop;
  100.   BOOL Done;
  101.   BOOL LoginOK=TRUE;
  102.  
  103.   DOOR_DisplayScreen("HBBS:System/Data/Private");
  104.  
  105.   DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW "Checking Your Account... Hold 1 sec!\r\n");
  106.  
  107.   strcpy(outstr,"HBBS:System/Data/ConfAcs");
  108.   AddPart(outstr,N_ND->User.CallData.ConfAcsDataFile,1024);
  109.   strcat(outstr,".CFG");
  110.   if (!PathOK(outstr))
  111.   {
  112.     sprintf(outstr,"User: %s, conf acs file %s is missing!!\r\n",N_ND->User.CallData.Handle,N_ND->User.CallData.ConfAcsDataFile);
  113.     HBBS_LogError(BBSGlobal->ErrorLogFile,ERR_GENERAL,outstr,TYPE_IMPORTANT);
  114.     DOOR_WriteText("Your conference access settings could not be found, unable to join any\r\n"
  115.                    "conferences.  The sysop has been notified of this problem.\r\n");
  116.     DOOR_PausePrompt("Press A Key To Confinue");
  117.     LoginOK=FALSE;
  118.   }
  119.  
  120.   if (!HBBS_AllowConfAccess(N_ND->User.CallData.LastConf))
  121.   {
  122.     // Users conference is invalid, let's join the first conference we're allowed access to
  123.     Done=FALSE;
  124.     for (loop=1; loop <=BBSGlobal->Conferences && !Done ;loop++)
  125.     {
  126.       if (HBBS_AllowConfAccess(loop))
  127.       {
  128.         N_ND->User.CallData.LastConf=loop;
  129.         N_ND->User.NormalData.LastConf=loop;
  130.         Done=TRUE;
  131.       }
  132.     }
  133.     if (!Done)
  134.     {
  135.  
  136.       sprintf(outstr,"User: %s cannot join a conference\r\n",N_ND->User.CallData.Handle);
  137.       HBBS_LogError(BBSGlobal->ErrorLogFile,ERR_GENERAL,outstr,TYPE_WARNING);
  138.       DOOR_WriteText("Sorry, there are no conferences you can access\r\n"
  139.                      "The sysop has been notified\r\n");
  140.       DOOR_PausePrompt("Press A Key To Leave A Comment");
  141.       DOOR_UserDoor("C",NULL);
  142.       LoginOK=FALSE;
  143.     }
  144.   }
  145.  
  146.   if (!(N_ND->User.CallData.Language>=1 && N_ND->User.CallData.Language<=BBSGlobal->Languages))
  147.   {
  148.     // Invalid Language, call language select door to fix.
  149.     sprintf(outstr,"User: %s had an invalid language\r\n",N_ND->User.CallData.Handle);
  150.     HBBS_LogError(BBSGlobal->ErrorLogFile,ERR_GENERAL,outstr,TYPE_WARNING);
  151.     DOOR_WriteText("You have an invalid language/ansi-type selected, please pick another\r\n");
  152.     DOOR_PausePrompt("Press A Key To Choose A Language");
  153.     DOOR_SystemDoor("SelectLanguage",NULL);
  154.   }
  155.   if (!LoginOK)
  156.   {
  157.     DOOR_Return("LOGIN_DENIED");
  158.   }
  159.  
  160. }
  161.  
  162. int main(int argc,char **argv)
  163. {
  164.   gargc=argc;
  165.   gargv=argv;
  166.  
  167.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  168.   {
  169.     printf("Invalid/No Paramaters for door!\n");
  170.     exit (20);
  171.   }
  172.   init("Checking Account");
  173.  
  174.   if (BBSGlobal=HBBS_GimmeBBS())
  175.   {
  176.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  177.     {
  178.       DoorMain();
  179.     }
  180.   }
  181.   cleanup(0);
  182. }
  183.